$(function(){
	//订单号
    var id = getvl("id");
    if (id != '') {
        $.ajax({
            url: urlcore + "/api/order/orderDetils?id="+id,
            type: "post",
            dataType: 'json',
            contentType: "application/json;charset=utf-8",
            success:function(data){
                if (data.success == true) {
                    var da = data.data;
                    var orderStatus=orderStatusStr(da.orderStatus)
                    $('#orderNumber').text(da.orderNumber);
                    $('#gmtDatetime').text(da.gmtDatetime);
                    $('#nickName').text(da.shop.nickName);
                    $('#adressDetail').text(da.addressUser.addressDetail);
                    $('#phone').text(da.addressUser.phone);
                  	if(da.ride!=null){
                    	 $('#realName').text(da.ride.realName);               
                    }else{
                    	 $('#realName').text("");   
                    }
                    $('#orderStatus').text(orderStatus);
                    $('#goodsMoney').text(da.goodsMoney);
                    $('#sendMoney').text(da.sendMoney);
                    $('#orderTip').text(da.orderTip);
                    $('#orderMark').text(da.orderMark);
                } else if (data.code == 'OVERTIME'){
                    var thisUrl = window.location.href;
                    if (thisUrl.indexOf('login.html') <= -1) {
                        top.window.location.href="login.html";
                    }
                } else {
                    alert(data.msg);
                }
            },
            error:function() {
                /* Act on the event */
                alert("error");
            }
        });
    }

});

/**
 * 用户状态返回
 * @param {Object} orderStatus
 */
function orderStatusStr(orderStatus){
	if (orderStatus==1) {
		orderStatus = '待抢单';
	}else if(orderStatus==2) {
		orderStatus = '待取货';
	}
	else if(orderStatus==3) {
		orderStatus = '配送中';
	}
	else if(orderStatus==4) {
		orderStatus = '已送达';
	}
	else if(orderStatus==6) {
		orderStatus = '货物损坏';
	}
	else if(orderStatus==8) {
		orderStatus = '订单未抢取消';
	}
	else if(orderStatus==9) {
		orderStatus = '已抢未取货取消';
	}
	else if(orderStatus==10) {
		orderStatus = '已配送取消';
	}
	return orderStatus;
}